package server

import (
	"errors"
	"strconv"
)

/**
生产者
*/
func Producer(name string, num int, mq chan string) (string, error) {
	result := 0
	var message string
	for i := 0; i < num; i++ {
		if mq == nil {
			return "", errors.New("chan is non ")
		}
		message = name + "--->" + strconv.Itoa(i)
		//fmt.Println("the producer info is", name, i)
		mq <- message
		result++
	}
	return strconv.Itoa(result), nil
}
